package com.pro.service.imple;

import com.pro.dao.CreatorMapper;
import com.pro.entity.ApplyRecordPuls;
import com.pro.entity.AuditLog;
import com.pro.service.CreatorServie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author ：刘弘禹
 * @description：TODO
 * @date ：2021/11/30 20:49
 * 创作者认证
 */
@Service
public class CreatorServieImple implements CreatorServie {
    @Autowired
    private CreatorMapper creatorMapper;

    @Override
    public List<ApplyRecordPuls> queryApplyRecord(ApplyRecordPuls applyRecordPuls) {
        if("".equals(applyRecordPuls.getApplyDate())){
            applyRecordPuls.setApplyDate(null);
        }
        List<ApplyRecordPuls> applyRecordPuls1 = creatorMapper.queryApplyRecord(applyRecordPuls);
        return applyRecordPuls1;
    }

    @Override
    public Boolean reviewApplication(ApplyRecordPuls applyRecordPuls,String state){
        if(state.equals("通过")){
            applyRecordPuls.setResult(3);
        }else{
            applyRecordPuls.setResult(4);
        }
        Boolean aBoolean = creatorMapper.reviewApplication(applyRecordPuls);
        if (aBoolean){
            AuditLog auditLog = new AuditLog();
            auditLog.setTableName("5");
            auditLog.setType( applyRecordPuls.getResult().toString());
            auditLog.setUserId(applyRecordPuls.getLaunchId());
            auditLog.setCreateDate(new Date());
            Boolean aBoolean1 = creatorMapper.addAuditLog(auditLog);
            return aBoolean1;
        }
        return false;
    }
}
